<?php 
	
	define('FILE_UPLOAD','upload');
	define('FILE_LOCAL','local');
	define('FILE_NET','net');
	
	
	interface IStorage{
		function save($path);
		function delete();
		function getInfo();
		function getUrl();
		function update();
	}
	
	class file4local implements IStorage{
		public $name;
		public $domain;
		public function __construct($domain,$fname){
			$this->name=$fname;
			$this->domain=$domain;
		}
		public function get(){}
		public function save($path){}
		public function delete(){}
		public function getInfo(){}
		public function getUrl(){}
		public function update(){}
		
	}
	
	class file4form extends file4local{
		
		public function save($path) {
			if(!move_uploaded_file($_FILES[$this->name]['tmp_name'], $path)){
				return false;
			}
			return true;
		}
		
		public function getName() {
			return $_FILES[$this->name]['name'];
		}
		
		public function getSize() {
			return $_FILES[$this->name]['size'];
		}
		
	}
	
	class file4net{}
	
	class file{
		public static function get($domain='',$fname=''){
			switch($domain){
				case FILE_UPLOAD:
					$f=new file4form($domain,$fname);
					break;
				case FILE_NET:
					$f=new file4net($domain,$fname);
					break;
				default:
					$f=new file4local($domain,$fname);
			}
			return $f;
		}
	}
